package com.hex.ds.hdtp.core.inf.script.test.repository.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hex.ds.hdtp.core.inf.common.page.Page;
import com.hex.ds.hdtp.core.inf.common.page.converter.IPageAndMyBatisPlusPageConverter;
import com.hex.ds.hdtp.core.inf.script.test.mapper.IScriptDataTestListMapper;
import com.hex.ds.hdtp.core.inf.script.test.po.ScriptDataTestListPo;
import com.hex.ds.hdtp.core.inf.script.test.repository.IScriptDataTestListRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Package: com.hex.ds.hdtp.core.inf.script.test.repository.impl
 * @ClassName ScriptDataTestListRepository
 * @Description: 带数据测试脚本清单-数据接口实现
 * @Author: wz.li
 * @Date 2023/8/1 14:50
 * @Version v2.0.2
 **/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptDataTestListRepository implements IScriptDataTestListRepository {

    private final IScriptDataTestListMapper scriptDataTestListMapper;

    private final IPageAndMyBatisPlusPageConverter pageConverter;

    /*
     * @Method: queryListByPage <br>
     * @Param: [scriptDataTestListPo, toPage] <br>
     * @Return: com.hex.ds.hdtp.core.inf.common.page.Page<com.hex.ds.hdtp.core.inf.script.test.po.ScriptDataTestListPo> <br>
     * @Description：分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 14:50 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Page<ScriptDataTestListPo> queryListByPage(ScriptDataTestListPo scriptDataTestListPo, Page toPage) {
        final IPage tmpPageResult = scriptDataTestListMapper.queryListByPage(
                pageConverter.toMyBatisPlusPage(toPage)
                , scriptDataTestListPo
        );
        final List list = tmpPageResult.getRecords();
        final Page pageResult = pageConverter.toPage(tmpPageResult);
        return pageResult.setData(list);
    }

    /*
     * @Method: queryConsanguinityListByPage <br>
     * @Param: [scriptDataTestListPo, toPage] <br>
     * @Return: com.hex.ds.hdtp.core.inf.common.page.Page<com.hex.ds.hdtp.core.inf.script.test.po.ScriptDataTestListPo> <br>
     * @Description：分页查询测试脚本的血缘<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/3 17:47 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Page<ScriptDataTestListPo> queryConsanguinityListByPage(ScriptDataTestListPo scriptDataTestListPo, Page toPage) {
        final IPage tmpPageResult = scriptDataTestListMapper.queryConsanguinityListByPage(
                pageConverter.toMyBatisPlusPage(toPage)
                , scriptDataTestListPo
        );
        final List list = tmpPageResult.getRecords();
        final Page pageResult = pageConverter.toPage(tmpPageResult);
        return pageResult.setData(list);
    }

    /*
     * @Method: queryList <br>
     * @Param: [scriptDataTestListPo] <br>
     * @Return: java.util.List<com.hex.ds.hdtp.core.inf.script.test.po.ScriptDataTestListPo> <br>
     * @Description：不分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 14:51 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public List<ScriptDataTestListPo> queryList(ScriptDataTestListPo scriptDataTestListPo) {
        return scriptDataTestListMapper.queryList(scriptDataTestListPo);
    }

    /*
     * @Method: queryById <br>
     * @Param: [pkId] <br>
     * @Return: com.hex.ds.hdtp.core.inf.script.test.po.ScriptDataTestListPo <br>
     * @Description：根据主键查询 <br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 14:51 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public ScriptDataTestListPo queryById(String pkId) {
        return scriptDataTestListMapper.selectById(pkId);
    }

    /*
     * @Method: add <br>
     * @Param: [scriptDataTestListPo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：新增<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 14:51 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer add(ScriptDataTestListPo scriptDataTestListPo) {
        return scriptDataTestListMapper.insert(scriptDataTestListPo);
    }

    /*
     * @Method: modifyById <br>
     * @Param: [scriptDataTestListPo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据主键更新<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 14:51 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer modifyById(ScriptDataTestListPo scriptDataTestListPo) {
        return scriptDataTestListMapper.updateById(scriptDataTestListPo);
    }

    /*
     * @Method: removeById <br>
     * @Param: [pkId] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据主键删除<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 14:51 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer removeById(String pkId) {
        return scriptDataTestListMapper.deleteById(pkId);
    }
}
